package inabit.data.expression.arithmetic;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import inabit.base.WorkingMemory;
/**Returns the value of the variable represented by this expression
 * @author Rafael Rocha*/
public class VariableExpression implements ArithmeticExpression{
	private String variable;
	
	/**@param
	 * variable = id of the variable represented by this expression*/
	public VariableExpression(String variable) {
		this.variable = variable;
	}
	@Override
	public String getResult(WorkingMemory wm) {
		return wm.getVariable(variable).getValue();
	}

	@Override
	public String stringForm() {
		return variable;
	}
	@Override
	public Collection<String> getReferenced() {
		List<String> all = new ArrayList<String>();
		all.add(variable);
		return all;
	}
	@Override
	public boolean isLeaf() {
		return true;
	}

}
